<template>
  <div class="img-list">
    <router-link :to="'/home/imgCon/' + item.id" tag="div" class="img-item" v-for="item in imgBox" :key="item.id">
      <img
        :src="item.images.small"
        alt
      >
      <h1 class="title">{{item.title}}</h1>
      <div class="info">
        <p class="price">
          <span class="now">{{ item.year }}</span>
          <span class="old">年上映</span>
        </p>
        <p class="sell">
          <span>热映中</span>
          <span>有{{item.collect_count}}人参与评论</span>
        </p>
      </div>
    </router-link>
    <mt-button type="danger" size="large" @click="getMore">加载更多</mt-button>
  </div>
</template>

<script>
import { Toast, Indicator} from "mint-ui";
const API_PROXY = "https://bird.ioliu.cn/v1/?url=";
export default {
  data() {
    return {
      count: 10,
      imgBox: []
    };
  },
  created() {
    this.getImg();
  },
  methods: {
    getImg() {
      Indicator.open({ text: "加载中...", spinnerType: "fading-circle" });
      this.$http
        .get(API_PROXY + "https://api.douban.com/v2/movie/in_theaters?start=0&count=" + this.count)
        .then(result => {
          if (result.body.start == 0) {
            this.imgBox = result.body.subjects;
            Indicator.close();
          } else {
            Toast("图片加载失败...")
            Indicator.close();
          }
        });
    },
    getMore(){
      this.count = this.count + 10;
      this.getImg();
    }
  }
};
</script>

<style lang="scss" scoped>
.img-list {
  display: flex;
  flex-wrap: wrap;
  padding: 0 8px;
  justify-content: space-between;
  width: 100%;
  .img-item {
    width: 49%;
    box-shadow: 0 0 8px #ccc;
    padding: 2px;
    margin: 4px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 5px;
    min-height: 290px;
    img {
      width: 100%;
    }
    .title {
      font-size: 14px;
    }
    .info {
      background-color: #eee;

      p {
        margin: 0;
        padding: 5px;
      }
      .price {
        .now {
          color: red;
          font-weight: bold;
        }
        .old {
          // text-decoration: line-through;
          color: black;
          font-size: 13px;
        }
      }
      .sell {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
      }
    }
  }
}
</style>
